home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / nihcl-30.lha / nihcl-3.0 / lib / Stack.c < prev    next >
C/C++ Source or Header  |  1990-05-19  |  3KB  |  128 lines

  1. /* Stack.c -- implementation of class Stack
  2.  
  3.     THIS SOFTWARE FITS THE DESCRIPTION IN THE U.S. COPYRIGHT ACT OF A
  4.     "UNITED STATES GOVERNMENT WORK".  IT WAS WRITTEN AS A PART OF THE
  5.     AUTHOR'S OFFICIAL DUTIES AS A GOVERNMENT EMPLOYEE.  THIS MEANS IT
  6.     CANNOT BE COPYRIGHTED.  THIS SOFTWARE IS FREELY AVAILABLE TO THE
  7.     PUBLIC FOR USE WITHOUT A COPYRIGHT NOTICE, AND THERE ARE NO
  8.     RESTRICTIONS ON ITS USE, NOW OR SUBSEQUENTLY.
  9.  
  10. Author:
  11.     K. E. Gorlen
  12.     Bg. 12A, Rm. 2033
  13.     Computer Systems Laboratory
  14.     Division of Computer Research and Technology
  15.     National Institutes of Health
  16.     Bethesda, Maryland 20892
  17.     Phone: (301) 496-1111
  18.     uucp: uunet!nih-csl!kgorlen
  19.     Internet: kgorlen@alw.nih.gov
  20.     October, 1985
  21.  
  22. Function:
  23.     
  24. Member function definitions for class Stack.
  25.  
  26. $Log:    Stack.c,v $
  27.  * Revision 3.0  90/05/20  00:21:27  kgorlen
  28.  * Release for 1st edition.
  29.  * 
  30. */
  31.  
  32. #include "Stack.h"
  33. #include "nihclIO.h"
  34.  
  35. #define    THIS    Stack
  36. #define    BASE    SeqCltn
  37. #define BASE_CLASSES BASE::desc()
  38. #define MEMBER_CLASSES OrderedCltn::desc()
  39. #define VIRTUAL_BASE_CLASSES
  40.  
  41. DEFINE_CLASS(Stack,2,"$Header: /afs/alw.nih.gov/unix/sun4_40c/usr/local/src/nihcl-3.0/share/lib/RCS/Stack.c,v 3.0 90/05/20 00:21:27 kgorlen Rel $",NULL,NULL);
  42.  
  43. Stack::Stack(unsigned size) : contents(size) {}
  44.  
  45. Stack::Stack(const Stack& s) : contents(s.contents) {}
  46.  
  47. Object* Stack::add(Object& ob)    { return contents.add(ob); }
  48.  
  49. Object*& Stack::at(int i)            { return contents.at(size()-i-1); }
  50.  
  51. const Object *const& Stack::at(int i) const    { return contents.at(size()-i-1); }
  52.  
  53. unsigned Stack::capacity() const    { return contents.capacity(); }
  54.  
  55. void Stack::deepenShallowCopy()
  56. {
  57.     BASE::deepenShallowCopy();
  58.     contents.deepenShallowCopy();
  59. }
  60.  
  61. unsigned Stack::hash() const        { return contents.hash(); }
  62.  
  63. bool Stack::isEmpty() const        { return contents.size()==0; }
  64.  
  65. Object* Stack::last() const        { return contents.last(); }
  66.  
  67. void Stack::reSize(unsigned newSize) { contents.reSize(newSize); }
  68.  
  69. void Stack::removeAll()
  70. {
  71.     contents.removeAll();
  72. }
  73.  
  74. Object* Stack::removeLast()    { return contents.removeLast(); }
  75.  
  76. unsigned Stack::size() const        { return contents.size(); }
  77.  
  78. Stack::Stack(OIOin& strm)
  79. :
  80. #ifdef MI
  81.     Object(strm),
  82. #endif
  83.     BASE(strm),
  84.     contents(strm)
  85. {
  86. }
  87.  
  88. void Stack::storer(OIOout& strm) const
  89. {
  90.     BASE::storer(strm);
  91.     contents.storeMemberOn(strm);
  92. }
  93.  
  94. Stack::Stack(OIOifd& fd)
  95. :
  96. #ifdef MI
  97.     Object(fd),
  98. #endif
  99.     BASE(fd),
  100.     contents(fd)
  101. {
  102. }
  103.  
  104. void Stack::storer(OIOofd& fd) const
  105. {
  106.     BASE::storer(fd);
  107.     contents.storeMemberOn(fd);
  108. }
  109.  
  110. void Stack::atAllPut(Object&)    { shouldNotImplement("atAllPut"); }
  111.  
  112. int Stack::indexOfSubCollection(const SeqCltn& /* cltn */, int /* start */) const
  113. {
  114.     shouldNotImplement("indexOfSubCollection");
  115.     return 0;
  116. }
  117.  
  118. Object* Stack::remove(const Object&)
  119. {
  120.     shouldNotImplement("remove");
  121.     return 0;
  122. }
  123.  
  124. void Stack::replaceFrom(int /* start */, int /* stop */, const SeqCltn&  /* replacement */, int /* startAt */)
  125. {
  126.     shouldNotImplement("replaceFrom");
  127. }
  128.